package com.tang.portal.controller.admin.sys;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tang.framework.core.controller.BaseController;
import com.tang.framework.core.domain.HttpResult;

import com.tang.common.model.req.ReqId;
import com.tang.common.model.res.ResSysDictValueTableItem;
import com.tang.framework.log.OperateLog;
import com.tang.framework.log.enums.OperateType;
import com.tang.portal.facade.admin.sys.SysDictValueFacade;
import com.tang.service.admin.model.req.ReqSysDictValue;
import com.tang.service.admin.model.req.ReqSysDictValueAdd;
import com.tang.service.admin.model.res.ResSysDictValueDetail;
import com.tang.common.model.req.ReqIds;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import lombok.SneakyThrows;
import jakarta.annotation.Resource;

/**
 * @author tang jun liang
 * @Date ${gen.dateTime}
 */
@RestController
@RequestMapping("/sys/dict/value")
public class SysDictValueController extends BaseController {

    @Resource
    private SysDictValueFacade sysDictValueFacade;


    @OperateLog(type = OperateType.DELETE, value = "字典值")
    @Operation(summary = "删除字典值")
    @PostMapping("/remove")
    public HttpResult<String> remove(@RequestBody ReqIds ids) {
        return sysDictValueFacade.remove(ids, getCurrLoginUser());
    }

    @Operation(summary = "字典值详情")
    @PostMapping("/detail")
    public HttpResult<ResSysDictValueDetail> detail(@RequestBody ReqId id) {
        return sysDictValueFacade.detail(id, getCurrLoginUser());
    }

    @Operation(summary = "字典值详情")
    @PostMapping("/list")
    public HttpResult<IPage<ResSysDictValueTableItem>> list(@RequestBody ReqSysDictValue reqSysDictValue) {
        return sysDictValueFacade.list(reqSysDictValue, getCurrLoginUser());
    }


    @OperateLog(type = OperateType.ADD, value = "字典值")
    @Operation(summary = "新增字典值")
    @PostMapping("/add")
    public HttpResult<String> add(@RequestBody ReqSysDictValueAdd sysDictValueAdd){
        return sysDictValueFacade.add(sysDictValueAdd);
    }

    @OperateLog(type = OperateType.UPDATE, value = "字典值")
    @Operation(summary = "编辑字典值")
    @PostMapping("/update")
    public HttpResult<String> update(@RequestBody ReqSysDictValueAdd sysDictValueAdd){
        return sysDictValueFacade.update(sysDictValueAdd);
    }


    @Operation(summary = "导出excel-字典值")
    @PostMapping("/export")
    public void export(@RequestBody ReqIds ids){
        sysDictValueFacade.export(ids, httpServletResponse);
    }

    @Operation(summary = "导出excel-模版")
    @PostMapping("/export/template")
    public void exportTemplate(){
        sysDictValueFacade.exportTemplate(httpServletResponse);
    }

    @OperateLog(type = OperateType.IMPORT, value = "字典值")
    @SneakyThrows
    @Operation(summary = "导入excel-字典值")
    @PostMapping("/import")
    public HttpResult<String> importExcel(MultipartFile file){
        return sysDictValueFacade.importExcel(file);
    }





}
